package com.zhouchb.test;

import jdk.internal.org.objectweb.asm.commons.TableSwitchGenerator;

import java.io.*;
import java.util.*;

/**
 * @Author Zhouchb
 * @Create 2021-12-2021/12/21 :12:46
 * @Description
 */
public class test11 {
    String name;
}

class hah {
    public static void main(String[] args) {
        test11 t = new test11();
        t.name = "hah";
        System.out.println(t.name);
    }
}

class test12 {
    public static void main(String[] args) {
//        File dir = new File("C:\\Users\\zhou\\Desktop\\www\\eeee");
//        System.out.println(dir.isFile());
//        dir.delete();
   //     System.out.println(Runtime.getRuntime().availableProcessors());
/*        for (File file : dir.listFiles()) {
            System.out.println(file);
        }
        for (String s : dir.list()) {
            System.out.println(s);
        }*/
        System.out.println(delDir(new File("C:\\Users\\zhou\\Desktop\\www")));
    }

    public static boolean delDir(File dir) {
        //dir.exists() #检查目录是否存在
        if (!dir.exists()) {
            return false;
        }
        if (dir.isFile()) {
//            isFile()：判断是否文件，也许可能是文件或者目录
//            exists()：判断是否存在，可能不存在
            return dir.delete();
        } else {
            for (File file : dir.listFiles()) {
                System.out.println(file.getName());
                delDir(file);
            }
        }
        return dir.delete();
    }
}
class MyStream{
    public static void main(String[] args) {
        FileInputStream fs = null;
        FileOutputStream fw = null;
        try {
            fs = new FileInputStream(new File("C:\\Users\\zhou\\Desktop\\xjpic.jpg"));
            fw = new FileOutputStream("hah.jpg");
            byte[] b = new byte[1024];
            int len;
            while ((len=fs.read(b))!=-1){
                fw.write(b,0,len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fs!=null){
                try {
                    fs.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fw!=null){
                try {
                    fw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }
}
class kuaipai{
    public static void main(String[] args) {
        int[] arr = new int[]{4,6,2,3,1,9};
        sort(arr,0,arr.length-1);
        System.out.println(Arrays.toString(arr));
    }
    public static void sort(int[] arr,int l,int r){
        if (l>=r){
            return;
        }
        int mid = partation(arr,l,r);
       sort(arr,l,mid-1);
       sort(arr,mid+1,r);
    }
    public static int partation(int[] arr,int l ,int r){
        int temp = arr[l];
        int left = l;
        int right = r;
        while (left<right){
            while (temp<=arr[right]&&left<right){
                right--;
            }
            while (temp>=arr[left]&&left<right){
                left++;
            }
            if (left<right){
                swap(arr,left,right);
            }
        }
        swap(arr,l,left);
        return left;
    }
    public static void swap(int[] arr,int i,int k){
        int key = arr[i];
        arr[i] = arr[k];
        arr[k] = key;
    }
}
class hdd{
    public static void main(String[] args) {
        int i =0;
        i+=i>0?--i:++i;
        System.out.println(i);
    }

    public boolean isPalindrome(int x) {
        String s = String.valueOf(x);
        char[] c = s.toCharArray();
        int i = c.length / 2;
        int k = c.length - 1;
        for (int j = 0; j <= i; j++, k--) {
            if (c[j] != c[k]) {
                return false;
            }
        }
        return true;
    }
}

class hahah{
    public static void main(String[] args) {
        int[] arr = new int[]{3,5,2,19,1,0,9,0};
        sort(arr,0,arr.length-1);
        System.out.println(Arrays.toString(arr));
    }
    public static void sort(int[] arr,int l ,int r){
        if (l>=r){
            return;
        }
        int mid = partition(arr, l, r);
        sort(arr,l,mid-1);
        sort(arr,mid+1,r);
    }
    public static int partition(int[] arr ,int l,int r){
        int key = arr[l];
        while (l<r){
            while (l<r && arr[r]>=key){
                r--;
            }
                swap(arr,l,r);
                if (l<r){
                }
           while (l<r && arr[l]<=key){
                l++;
             }
            if (l<r){
                swap(arr,l,r);
            }
        }
        return l;
    }
    public static void swap(int[] arr ,int l,int r){
        int temp = arr[l];
        arr[l] = arr[r];
        arr[r] = temp;
    }
}

class std implements Comparable{
    int age ;
    String name;

    public std(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "std{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        if (o instanceof Comparable){
            std o1 = (std) o;
            if (this.age>o1.age){
                return 1;
            }else if(this.age<o1.age){
                return -1;
            }else
                return 0;
        }
        throw new RuntimeException("类型不一致");
    }
}
class testc{
    public static void main(String[] args) {
        std[] stds = new std[3];
        stds[0]=new std(3,"小明");
        stds[1]=new std(1,"小红");
        stds[2]=new std(5,"小安");
        Arrays.sort(stds);
        System.out.println(Arrays.toString(stds));
        ArrayList<std> stds1 = new ArrayList<>();
        stds1.add(new std(3,"小明"));
        stds1.add(new std(1,"小红"));
        stds1.add(new std(5,"小天"));
        Collections.sort(stds1);
        System.out.println(stds1);
    }
}